//
// Created by 11510 on 2024/6/11.
//
#include <iostream>
using namespace std;

// 复数
class Complex{
private:
    int _real;
    int _image;

public:
    Complex(int real, int image):_real(real), _image(image){}

    void print() const{
        cout << _real << " + " << _image << "i" << endl;
    }

    /**
     * 前置++
     * @return
     */
    Complex &operator++(){
        cout << "前置++重载" << endl;
        ++_real;
        ++_image;
        return *this;
    }
    /**
     * 后置++与前置++的操作数一样
     * 在重载函数的参数列表中加上int，以示区分
     * @return
     */
    Complex operator++(int){
        cout << "后置++" << endl;

//        拷贝构造
        Complex backup(*this);
        _real++;
        _image++;
        return backup;
    }


};



void test0(){
    Complex cx1(1, 2);

    (cx1++).print();
    (++cx1).print();
}


int main() {
    test0();
    return 0;
}